//
//  GameOver.cpp
//  dot
//
//  Created by zz on 2019/6/21.
//

#include "GameOver.hpp"

GameOver *GameOver::create(int score){
    
    auto gameover = new GameOver();
    if(gameover&&gameover->init(score)){
    
        gameover->autorelease();
        return gameover;
    }else{
        
        CC_SAFE_DELETE(gameover);
        return NULL;
        
    }
}

bool GameOver::init(int score){
    
    if(!this->initWithColor(Color4B(120, 120, 120, 230))){
        
        return false;
    }

    auto size = Director::getInstance()->getVisibleSize();
    auto gameover =Label::create("Game Over","Arial",60);
    gameover->setPosition(Vec2(size.width/2,size.height/2+100));
    this->addChild(gameover);
    auto str =__String::createWithFormat("%i",score)->getCString();
    auto label = Label::create(str,"Arial",60);
    label->setPosition(size/2);
    this->addChild(label);

    return true;
}
